define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'org/orgstatus/index' + location.search,
                    add_url: 'org/orgstatus/add',
                    edit_url: 'org/orgstatus/edit',
                    del_url: 'org/orgstatus/del',
                    multi_url: 'org/orgstatus/multi',
                    table: 'org_cate',
                }
            });

            var table = $("#table");
            table.on('post-common-search.bs.table', function (event, table) {
                $(".commonsearch-table").find('.btn-success').html('搜索');
                $(".commonsearch-table").find('.btn-default').html('刷新');
                $('.form-commonsearch').attr('autocomplete', 'off');
            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'sort', title: __('序号'), operate:false},
                        {field: 'name', title: __('Name'), operate:false},
                        // {field: 'parent_id', title: __('Parent_id')},
                        // {field: 'level', title: __('Level')},
                        {field: 'mobile', title: __('Mobile'), operate:false},
                        {field: 'linkman', title: __('Linkman'), operate:false},
                        // {field: 'introduce', title: __('Introduce')},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'url', title: __('Url'), formatter: Table.api.formatter.url},
                        // {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'type', title: __('Type')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                showToggle: false,
                showColumns: false,
                showExport: false,
                searchFormVisible: true,
                search:true,
                onLoadSuccess:function(){
                    // 这里就是数据渲染结束后的回调函数
                    $(".btn-editone").data("area", ["100%","100%"]);
                    //$(".pull-right.search input").attr('placeholder', '请输入标题');
                    $(".columns-right").hide();
                }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});